
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
  <head>
    <meta charset="utf-8" />
    <title>调试和分析 &#8212; Python 3.7.8 文档</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/translations.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="在 Python 3.7.8 文档 中搜索"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="关于这些文档" href="../about.html" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="copyright" title="版权所有" href="../copyright.html" />
    <link rel="next" title="bdb --- Debugger framework" href="bdb.html" />
    <link rel="prev" title="test --- Python回归测试包" href="test.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/library/debug.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="bdb.html" title="bdb --- Debugger framework"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="test.html" title="test --- Python回归测试包"
             accesskey="P">上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python 标准库</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="debugging-and-profiling">
<h1>调试和分析<a class="headerlink" href="#debugging-and-profiling" title="永久链接至标题">¶</a></h1>
<p>这些库可以帮助你进行Python开发：调试器使你能够逐步执行代码，分析堆栈帧并设置断点等，而分析器运行代码并为你提供执行时间的详细分类，从而使你能够找出你程序中的瓶颈。</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="bdb.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">bdb</span></code> --- Debugger framework</a></li>
<li class="toctree-l1"><a class="reference internal" href="faulthandler.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">faulthandler</span></code> --- Dump the Python traceback</a><ul>
<li class="toctree-l2"><a class="reference internal" href="faulthandler.html#dumping-the-traceback">Dumping the traceback</a></li>
<li class="toctree-l2"><a class="reference internal" href="faulthandler.html#fault-handler-state">Fault handler state</a></li>
<li class="toctree-l2"><a class="reference internal" href="faulthandler.html#dumping-the-tracebacks-after-a-timeout">Dumping the tracebacks after a timeout</a></li>
<li class="toctree-l2"><a class="reference internal" href="faulthandler.html#dumping-the-traceback-on-a-user-signal">Dumping the traceback on a user signal</a></li>
<li class="toctree-l2"><a class="reference internal" href="faulthandler.html#issue-with-file-descriptors">Issue with file descriptors</a></li>
<li class="toctree-l2"><a class="reference internal" href="faulthandler.html#example">示例</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pdb.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pdb</span></code> --- Python的调试器</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pdb.html#debugger-commands">调试器命令</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="profile.html">Python 分析器</a><ul>
<li class="toctree-l2"><a class="reference internal" href="profile.html#introduction-to-the-profilers">分析器简介</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html#instant-user-s-manual">即时用户手册</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html#module-cProfile"><code class="xref py py-mod docutils literal notranslate"><span class="pre">profile</span></code> 和 <code class="xref py py-mod docutils literal notranslate"><span class="pre">cProfile</span></code> 模块参考</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html#the-stats-class"><code class="xref py py-class docutils literal notranslate"><span class="pre">Stats</span></code> 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html#what-is-deterministic-profiling">什么是确定性性能分析？</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html#limitations">局限性</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html#calibration">准确估量</a></li>
<li class="toctree-l2"><a class="reference internal" href="profile.html#using-a-custom-timer">使用自定义计时器</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="timeit.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">timeit</span></code> --- 测量小代码片段的执行时间</a><ul>
<li class="toctree-l2"><a class="reference internal" href="timeit.html#basic-examples">基本示例</a></li>
<li class="toctree-l2"><a class="reference internal" href="timeit.html#python-interface">Python 接口</a></li>
<li class="toctree-l2"><a class="reference internal" href="timeit.html#command-line-interface">命令行界面</a></li>
<li class="toctree-l2"><a class="reference internal" href="timeit.html#examples">例子</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="trace.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">trace</span></code> --- Trace or track Python statement execution</a><ul>
<li class="toctree-l2"><a class="reference internal" href="trace.html#command-line-usage">Command-Line Usage</a><ul>
<li class="toctree-l3"><a class="reference internal" href="trace.html#main-options">Main options</a></li>
<li class="toctree-l3"><a class="reference internal" href="trace.html#modifiers">Modifiers</a></li>
<li class="toctree-l3"><a class="reference internal" href="trace.html#filters">Filters</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="trace.html#programmatic-interface">编程接口</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="tracemalloc.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code> --- 跟踪内存分配</a><ul>
<li class="toctree-l2"><a class="reference internal" href="tracemalloc.html#examples">例子</a><ul>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#display-the-top-10">显示前10项</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#compute-differences">计算差异</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#get-the-traceback-of-a-memory-block">Get the traceback of a memory block</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#pretty-top">Pretty top</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="tracemalloc.html#api">API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#functions">函数</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#domainfilter">域过滤器</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#filter">过滤器</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#frame">Frame</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#snapshot">快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#statistic">统计</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#statisticdiff">StatisticDiff</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#trace">跟踪</a></li>
<li class="toctree-l3"><a class="reference internal" href="tracemalloc.html#traceback">回溯</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>上一个主题</h4>
  <p class="topless"><a href="test.html"
                        title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">test</span></code> ---  Python回归测试包</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="bdb.html"
                        title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">bdb</span></code> --- Debugger framework</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">提交 Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/library/debug.rst"
            rel="nofollow">显示源代码
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="bdb.html" title="bdb --- Debugger framework"
             >下一页</a> |</li>
        <li class="right" >
          <a href="test.html" title="test --- Python回归测试包"
             >上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">版权所有</a> 2001-2020, Python Software Foundation.
    <br />
    Python 软件基金会是一个非盈利组织。
    <a href="https://www.python.org/psf/donations/">请捐助。</a>
    <br />
    最后更新于 6月 29, 2020.
    <a href="../bugs.html">发现了问题</a>？
    <br />
    使用<a href="http://sphinx.pocoo.org/">Sphinx</a>2.3.1 创建。
    </div>

  </body>
</html>